package com.example.physicalexaminationsystem.controller;

import com.example.physicalexaminationsystem.dto.ResponseDto;
import com.example.physicalexaminationsystem.service.MealService;
import com.example.physicalexaminationsystem.vo.MealVO;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

/**
 * @author shiwenzhuo
 * 
 * @description
 */
@RestController
@RequestMapping("/api/meal")
public class MealController {

    @Resource
    private MealService mealService;

    //添加套餐信息
    @RequestMapping("/addMeal")
    public ResponseDto addMeal(@RequestBody Map<String, Object> params) {
        mealService.addMeal(params);
        return ResponseDto.success();
    }

    //修改套餐信息
    @RequestMapping("/updateMeal")
    public ResponseDto updateMeal(@RequestBody Map<String, Object> params) {
        mealService.updateMealByid(params);
        return ResponseDto.success();
    }

    //获取套餐信息
    @RequestMapping("/getMealList")
    public ResponseDto getMealList() {
        List<MealVO> allMeal = mealService.getAllMeal();
        return ResponseDto.success(allMeal);
    }

    //删除套餐信息
    @RequestMapping("/deleteMealById")
    public ResponseDto deleteMealById(@RequestParam  Long id) {
        mealService.deleteMealById(id);
        return ResponseDto.success();
    }

    //获取套餐类型枚举
    @RequestMapping("/getMealCategory")
    public ResponseDto getMealCategory() {
        return ResponseDto.success(mealService.getMealCategory());
    }
}
